package com.yueyang.sojourn.server.service.sojourn.projectshare;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yueyang.sojourn.server.model.enums.StatusEnum;
import com.yueyang.sojourn.server.model.po.SojournProjectShareLog;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 项目分账修改记录服务
 * @author andy.yang
 * @version v1
 * @summary
 * @Copyright (c) 2019, yueyang Group All Rights Reserved.
 * @since 2020/3/28
 */
@Service
public class SojournProjectShareLogService {
    @Resource
    SojournProjectShareLogMapper sojournProjectShareLogMapper;

    /**
     * 创建项目分账修改记录
     * @param shareLog
     * @return
     */
    public int add(SojournProjectShareLog shareLog){
        shareLog.setStatus(StatusEnum.VALID.getCode());
        return sojournProjectShareLogMapper.insert(shareLog);
    }


    /**
     * @param pageNo      页码
     * @param pageSize    页大小
     * @return
     * @author Andy.yang
     * @summary 订单分页查询
     * @version v1
     * @since 2020-03-28
     */
    public PageInfo<SojournProjectShareLog> findPage(Long projectId,int pageNo, int pageSize) {
        PageInfo<SojournProjectShareLog> pageInfo = PageHelper.startPage(pageNo, pageSize)
                .doSelectPageInfo(() -> sojournProjectShareLogMapper.findByProjectId(projectId));
        return pageInfo;
    }

    /**
     * @param shareLogId      项目分账修改记录id
     * @return
     * @author Andy.yang
     * @summary 查询
     * @version v1
     * @since 2020-03-28
     */
    public SojournProjectShareLog findById(Long shareLogId) {
        return sojournProjectShareLogMapper.selectByPrimaryKey(shareLogId);
    }

}
